package com.yd.app.mapper.jewellery.jewelleryPageMapper;

import com.yd.app.mapper.provider.EvaluateProvider;
import com.yd.app.mapper.provider.GoodsProvider;
import com.yd.domain.business.*;
import com.yd.domain.searchParam.GoodsSearchParam;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;

import java.util.List;

/**
 * @author zy
 * @create 2018-05-14 9:15
 * @desc 电脑前端数据展示
 **/
public interface WebSiteGoodsMapper {

    //查询商品数据
    @SelectProvider(method = "getGoodsList",type= GoodsProvider.class)
    List<Goods> getGoodsList(@Param("model")GoodsSearchParam param, @Param("startRow") int startRow, @Param("pageSize") int pageSize);
    //查询商品数量
    @SelectProvider(method = "getGoodsListCount",type= GoodsProvider.class)
    int getGoodsListCount(@Param("model")GoodsSearchParam param);
    //查询样式
    @Select("select * from business_gstyle where ifUse=1 AND pId=#{pId} order by sort")
    List<GStyle> getGStyleList(@Param("pId") String pId);
    //查询品型
    @Select("select * from business_pinxing where  pId=#{pId} ")
    List<PinXing> getPListByPId(@Param("pId")String pId);
    //获取一级分类
    @Select("select * from business_gtype_one order by sort")
    List<GTypeOne> getTypeOne();
    //获取商品类型二级分类
    @Select("select * from business_gType where ifUse=1 AND pId=#{pId} ")
    List<GType> getGTypeList(@Param("pId") String pId);
    //查询商品详细信息
    @Select(" select o.*,dic.typeName as typeName,gs.typeName as gstyleName,p.title as pxName FROM business_goods o  LEFT JOIN business_gType dic ON dic.id=o.type and dic.goodKind='1'" +
            "  LEFT JOIN business_gstyle gs ON o.gstyle=gs.id " +
            " LEFT JOIN business_pinxing p on o.px=p.id " +
            " where o.id=#{goodsId}")
    Goods getGoodsById(@Param("goodsId") String goodsId);
    // 查询商品规格
    @Select("select * from business_goods_weight where goodsId=#{goodsId} ")
    List<GoodsWeight> getGoodsWeight(@Param("goodsId") String goodsId);

    //根据条件分页查询评价信息
    @SelectProvider(method = "searchEvaluateList", type = EvaluateProvider.class)
    List<Evaluate> getEvaluateList(@Param("goodsId") String goodsId, @Param("startRow") int startRow, @Param("pageSize") int pageSize);
    // 查询评价信息数量
    @SelectProvider(method = "searchEvaluateCount", type = EvaluateProvider.class)
    int getEvaluateCount(@Param("goodsId") String goodsId);

    //查询商品图片
    @Select("select p.* from business_pic p where p.id IN (SELECT gp.picId from business_goods_pic gp where gp.goodsId=#{goodId})")
    List<Pic> getAllPic(@Param("goodId") String goodId);
}
